Skip to main content

CreateImage

Creates an image with the parameters specified.

Syntax

expression.CreateImage(sImageSrc, nWidth, nHeight);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sImageSrcRequiredstringThe image source where the image to be inserted should be taken from (currently, only internet URL or Base64 encoded images are supported).
nWidthRequiredEMUThe image width in English measure units.
nHeightRequiredEMUThe image height in English measure units.

Returns

ApiImage

Example

This example creastes an image and pastes it into the document.

var oPresentation = Api.GetPresentation();
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
var oShape = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/step2_1.png", 300 * 36000, 150 * 36000);
oSlide.AddObject(oShape);